:- consult('principal.pl').

listOfTests([Test]):- call(Test).
listOfTests([Test | R]):- listOfTests(R), call(Test).

testSuit(L):-
	retractall(ok(_X)),
        retractall(failed(_Y)),
	listOfTests(L).

testLegalMove(TestId, initialState(computer(PlayerC), moves(PlayerM), Chessboard), Piece, ExpectedResult):-
	setUpPosition(t, computer(PlayerC), moves(PlayerM), Chessboard),
	findall((File, Rank), legalMove(t, Piece, File, Rank), Result), 
	sort(Result, SResult), sort(ExpectedResult, SExpectedResult),
 		   (SResult = SExpectedResult -> assert(ok(TestId));
                                                 assert(failed(TestId))).

testKingInSpecialSituation(TestId, initialState(computer(PlayerC), moves(PlayerM), Chessboard), kingInCheck, ExpectedResult):-
	setUpPosition(t, computer(PlayerC), moves(PlayerM), Chessboard),
	findall(King, kingInCheck(t, King), Result), 
	sort(Result, SResult), sort(ExpectedResult, SExpectedResult),
 		   (SResult = SExpectedResult -> assert(ok(TestId));
                                                 assert(failed(TestId))).

testKingInSpecialSituation(TestId, initialState(computer(PlayerC), moves(PlayerM), Chessboard), kingInCheckmate, ExpectedResult):-
	setUpPosition(t, computer(PlayerC), moves(PlayerM), Chessboard),
	findall(King, kingInCheckmate(t, King), Result), 
	sort(Result, SResult), sort(ExpectedResult, SExpectedResult),
 		   (SResult = SExpectedResult -> assert(ok(TestId));
                                                 assert(failed(TestId))).

testKingInSpecialSituation(TestId, initialState(computer(PlayerC), moves(PlayerM), Chessboard), kingInStalmate, ExpectedResult):-
	setUpPosition(t, computer(PlayerC), moves(PlayerM), Chessboard),
	findall(King, kingInStalmate(t, King), Result), 
	sort(Result, SResult), sort(ExpectedResult, SExpectedResult),
 		   (SResult = SExpectedResult -> assert(ok(TestId));
                                                 assert(failed(TestId))).


% MOVES OF THE PIECES

testSuitKingMoves(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testKing(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testKing(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

testSuitQueenMoves(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testQueen(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testQueen(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

testSuitBishopMoves(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testBishop(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testBishop(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

testSuitRookMoves(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testRook(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testRook(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

testSuitKnightMoves(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testKnight(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testKnight(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

% KING IN CHECK, CHECKMATE OR STALMATE

testSuitKingInCheck(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testKingInCheck(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testKingInCheck(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

testSuitKingInCheckmate(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testKingInCheckmate(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testKingInCheckmate(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions

testSuitKingInStalmate(ListOfOk, ListOfFailed):-
	findall(OK, (testSuit([testKingInStalmate(_X)]), ok(OK)), UListOfOk),
	sort(UListOfOk, ListOfOk), % sort/2 is used to avoid repetitions
	findall(Failed, (testSuit([testKingInStalmate(_Y)]), failed(Failed)), UListOfFailed),
	sort(UListOfFailed, ListOfFailed). % sort/2 is used to avoid repetitions


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

testKing(1) :-
      testLegalMove(testKing1,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), a, 1), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (d, 3), (f, 3), (d, 2), (e, 2), (f, 2)]).

testKing(2) :-
      testLegalMove(testKing2,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(e, 4), (f, 4), (d, 3), (f, 3), (d, 2), (e, 2), (f, 2)]).

testKing(3) :-
      testLegalMove(testKing3,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), e, 4), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (f, 4), (d, 3), (f, 3), (d, 2), (e, 2), (f, 2)]).

testKing(4) :-
      testLegalMove(testKing4,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), f, 4), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (d, 3), (f, 3), (d, 2), (e, 2), (f, 2)]).

testKing(5) :-
      testLegalMove(testKing5,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 3), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (f, 3), (d, 2), (e, 2), (f, 2)]).

testKing(6) :-
      testLegalMove(testKing6,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), f, 3), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (d, 3), (d, 2), (e, 2), (f, 2)]).

testKing(7) :-
      testLegalMove(testKing7,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 2), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (d, 3), (f, 3), (e, 2), (f, 2)]).

testKing(8) :-
      testLegalMove(testKing8,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), e, 2), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (d, 3), (f, 3), (d, 2), (f, 2)]).

testKing(9) :-
      testLegalMove(testKing9,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), f, 2), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (d, 3), (f, 3), (d, 2), (e, 2)]).

testKing(10) :-
      testLegalMove(testKing10,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 8), (whiteKing(1), e, 3), (blacking(1), e, 8)]),
      whiteKing(1),
      [(e, 4), (f, 4), (f, 3), (e, 2), (f, 2)]).

testKing(11) :-
      testLegalMove(testKing11,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), f, 8), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (d, 3), (d, 2), (e, 2)]).

testKing(12) :-
      testLegalMove(testKing12,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), a, 4), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 3), (f, 3), (d, 2), (e, 2), (f, 2)]).

testKing(13) :-
      testLegalMove(testKing13,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), a, 2), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 4), (d, 3), (f, 3)]).

testKing(14) :-
      testLegalMove(testKing14,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 4), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (f, 3), (e, 2), (f, 2)]).

testKing(15) :-
      testLegalMove(testKing15,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), e, 4), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(e, 4), (d, 3), (f, 3), (d, 2), (f, 2)]).

testKing(16) :-
      testLegalMove(testKing16,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), f, 4), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(f, 4), (d, 3), (d, 2), (e, 2)]).

testKing(17) :-
      testLegalMove(testKing17,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 3), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(e, 4), (f, 4), (d, 3), (e, 2), (f, 2)]).

testKing(18) :-
      testLegalMove(testKing18,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), f, 3), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (f, 3), (d, 2), (e, 2)]).

testKing(19) :-
      testLegalMove(testKing19,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 2), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(e, 4), (f, 4), (f, 3), (d, 2)]).

testKing(20) :-
      testLegalMove(testKing20,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), e, 2), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (f, 4), (d, 3), (f, 3), (e, 2)]).

testKing(21) :-
      testLegalMove(testKing21,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), f, 2), (whiteKing(1), e, 3), (blackKing(1), e, 8)]),
      whiteKing(1),
      [(d, 4), (e, 4), (d, 3), (f, 2)]).

testKingInCheck(22) :-
      testKingInSpecialSituation(testKingInCheck1,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteRook(1), a, 1), (whiteKing(1), e, 1), (whiteRook(2), h, 1), (blackKing(1), a, 8)]),
      kingInCheck,
      [blackKing(1)]).

testKingInCheckmate(23) :-
      testKingInSpecialSituation(testKingInCheckmate1,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteRook(1), a, 1), (whiteKing(1), e, 1), (whiteRook(2), h, 1), (blackKing(1), a, 8)]),
      kingInCheckmate,
      []).

testKingInCheckmate(24) :-
      testKingInSpecialSituation(testKingInCheckmate2,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteRook(1), a, 8), (whiteKing(1), e, 1), (whiteRook(2), h, 7), (blackKing(1), e, 8)]),
      kingInCheckmate,
      [blackKing(1)]).

testKingInCheckmate(25) :-
      testKingInSpecialSituation(testKingInCheckmate3,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteRook(1), a, 8), (whiteKing(1), e, 6), (blackKing(1), e, 8)]),
      kingInCheckmate,
      [blackKing(1)]).

testKingInCheckmate(26) :-
      testKingInSpecialSituation(testKingInCheckmate4,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteQueen(1), f, 8), (whiteKing(1), g, 6), (blackKing(1), h, 8)]),
      kingInCheckmate,
      [blackKing(1)]).

testKingInCheckmate(27) :-
      testKingInSpecialSituation(testKingInCheckmate5,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteQueen(1), g, 7), (whiteKing(1), g, 6), (blackKing(1), h, 8)]),
      kingInCheckmate,
      [blackKing(1)]).

testKingInCheckmate(28) :-
      testKingInSpecialSituation(testKingInCheckmate6,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteBishop(1), d, 4), (whiteBishop(2), e, 4), (whiteKing(1), g, 3), (blackKing(1), h, 1)]),
      kingInCheckmate,
      [blackKing(1)]).

testKingInCheckmate(29) :-
      testKingInSpecialSituation(testKingInCheckmate7,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteRook(1), a, 8), (whiteKing(1), e, 6), (blackKnight(1), f, 7), (blackKing(1), e, 8)]),
      kingInCheckmate,
      []).

testKingInStalmate(30) :-
      testKingInSpecialSituation(testKingInStalmate1,
              initialState(computer(whitePlayer), moves(blackPlayer),
      [(whiteQueen(1), f, 7), (whiteKing(1), e, 5), (blackKing(1), h, 8)]),
      kingInStalmate,
      [blackKing(1)]).

testQueen(31) :-
      testLegalMove(testQueen1,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(32) :-
      testLegalMove(testQueen2,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), d, 2), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(33) :-
      testLegalMove(testQueen3,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), d, 7), (blackKing(1), f, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(34) :-
      testLegalMove(testQueen4,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), b, 4), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(35) :-
      testLegalMove(testQueen5,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), g, 4), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(36) :-
      testLegalMove(testQueen6,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), b, 2), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(37) :-
      testLegalMove(testQueen7,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), g, 7), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(38) :-
      testLegalMove(testQueen8,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), f, 2), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3)]).

testQueen(39) :-
      testLegalMove(testQueen9,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (whiteKing(1), b, 6), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(40) :-
      testLegalMove(testQueen10,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), d, 2), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(41) :-
      testLegalMove(testQueen11,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), d, 7), (whiteKing(1), e, 1), (blackKing(1), f, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(42) :-
      testLegalMove(testQueen12,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), b, 4), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(43) :-
      testLegalMove(testQueen13,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), g, 4), (whiteKing(1), h, 2), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(44) :-
      testLegalMove(testQueen14,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), b, 2), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(45) :-
      testLegalMove(testQueen15,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), g, 7), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(46) :-
      testLegalMove(testQueen16,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), f, 2), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (a, 7), (b, 6), (c, 5), (e, 3), (f, 2)]).

testQueen(47) :-
      testLegalMove(testQueen17,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteQueen(1), d, 4), (blackRook(1), b, 6), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      whiteQueen(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4), (a, 1), (b, 2), (c, 3), (e, 5), (f, 6), (g, 7), (h, 8), (b, 6), (c, 5), (e, 3), (f, 2), (g, 1)]).

testQueen(48) :-
      testLegalMove(testQueen18,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 8), (whiteQueen(1), d, 4), (whiteKing(1), d, 3), (blackKing(1), c, 7)]),
      whiteQueen(1),
      [(d, 5), (d, 6), (d, 7), (d, 8)]).

testQueen(49) :-
      testLegalMove(testQueen19,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), h, 4), (whiteQueen(1), d, 4), (whiteKing(1), c, 4), (blackKing(1), c, 7)]),
      whiteQueen(1),
      [(e, 4), (f, 4), (g, 4), (h, 4)]).

testBishop(50) :-
      testLegalMove(testBishop1,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), h, 2), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (g, 6), (h, 7), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(51) :-
      testLegalMove(testBishop2,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), h, 3), (whiteKing(1), e, 1), (blackKing(1), c, 2)]),
      blackBishop(1),
      [(d, 3), (f, 5), (g, 6), (h, 7), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(52) :-
      testLegalMove(testBishop3,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), h, 3), (whiteKing(1), e, 1), (blackKing(1), g, 6)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(53) :-
      testLegalMove(testBishop4,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), h, 3), (whiteKing(1), e, 1), (blackKing(1), g, 2)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (g, 6), (h, 7), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(54) :-
      testLegalMove(testBishop5,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), h, 3), (whiteKing(1), e, 1), (blackKing(1), b, 7)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (g, 6), (h, 7), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6)]).

testBishop(55) :-
      testLegalMove(testBishop6,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), g, 6), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (g, 6), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(56) :-
      testLegalMove(testBishop7,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), c, 2), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      blackBishop(1),
      [(c, 2), (d, 3), (f, 5), (g, 6), (h, 7), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(57) :-
      testLegalMove(testBishop8,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), b, 7), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (g, 6), (h, 7), (h, 1), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7)]).

testBishop(58) :-
      testLegalMove(testBishop9,
              initialState(computer(blackPlayer), moves(whitePlayer),
      [(blackBishop(1), e, 4), (whiteRook(1), g, 2), (whiteKing(1), e, 1), (blackKing(1), e, 8)]),
      blackBishop(1),
      [(b, 1), (c, 2), (d, 3), (f, 5), (g, 6), (h, 7), (g, 2), (f, 3), (d, 5), (c, 6), (b, 7), (a, 8)]).

testBishop(59) :-
      testLegalMove(testBishop10,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 8), (whiteBishop(1), d, 4), (whiteKing(1), d, 3), (blackKing(1), c, 7)]),
      whiteBishop(1),
      []).

testBishop(60) :-
      testLegalMove(testBishop11,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), h, 4), (whiteBishop(1), d, 4), (whiteKing(1), c, 4), (blackKing(1), c, 7)]),
      whiteBishop(1),
      []).

testRook(61) :-
      testLegalMove(testRook1,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), e, 3), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(62) :-
      testLegalMove(testRook2,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), d, 2), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(63) :-
      testLegalMove(testRook3,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), d, 7), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(64) :-
      testLegalMove(testRook4,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), b, 4), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(65) :-
      testLegalMove(testRook5,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), g, 4), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4)]).

testRook(66) :-
      testLegalMove(testRook6,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), e, 3), (blackBishop(1), d, 2), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 2)]).

testRook(67) :-
      testLegalMove(testRook7,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), f, 3), (blackBishop(1), d, 2), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(68) :-
      testLegalMove(testRook8,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), e, 3), (blackBishop(1), d, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(69) :-
      testLegalMove(testRook9,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), e, 3), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(70) :-
      testLegalMove(testRook10,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteRook(1), d, 4), (whiteKing(1), e, 3), (blackBishop(1), g, 7), (blackKing(1), g, 8)]),
      whiteRook(1),
      [(d, 1), (d, 2), (d, 3), (d, 5), (d, 6), (d, 7), (d, 8), (a, 4), (b, 4), (c, 4), (e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(71) :-
      testLegalMove(testRook11,
              initialState(computer(blackPlayer), moves(blackPlayer),
      [(whiteQueen(1), d, 8), (blackRook(1), d, 4), (whiteKing(1), b, 3), (blackKing(1), d, 3)]),
      blackRook(1),
      [(d, 5), (d, 6), (d, 7), (d, 8)]).

testRook(72) :-
      testLegalMove(testRook12,
              initialState(computer(blackPlayer), moves(blackPlayer),
      [(blackRook(1), d, 4), (whiteQueen(1), h, 4), (blackKing(1), c, 4), (whiteKing(1), h, 5)]),
      blackRook(1),
      [(e, 4), (f, 4), (g, 4), (h, 4)]).

testRook(73) :-
      testLegalMove(testRook13,
              initialState(computer(blackPlayer), moves(blackPlayer),
      [(whiteBishop(1), b, 3), (blackRook(1), d, 5), (whiteKing(1), f, 2), (blackKing(1), e, 6)]),
      blackRook(1),
      []).

testRook(74) :-
      testLegalMove(testRook14,
              initialState(computer(blackPlayer), moves(blackPlayer),
      [(whiteBishop(1), f, 3), (blackRook(1), d, 5), (whiteKing(1), f, 2), (blackKing(1), c, 6)]),
      blackRook(1),
      []).

testKnight(75) :-
      testLegalMove(testKnight1,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteKnight(1), d, 4), (whiteKing(1), e, 1), (blackRook(1), f, 7), (blackKing(1), g, 8)]),
      whiteKnight(1),
      [(b, 3), (c, 2), (e, 2), (f, 3), (f, 5), (e, 6), (c, 6), (b, 5)]).

testKnight(76) :-
      testLegalMove(testKnight2,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteKnight(1), d, 4), (whiteKing(1), b, 3), (blackRook(1), f, 7), (blackKing(1), g, 8)]),
      whiteKnight(1),
      [(c, 2), (e, 2), (f, 3), (f, 5), (e, 6), (c, 6), (b, 5)]).

testKnight(77) :-
      testLegalMove(testKnight3,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(whiteKnight(1), d, 4), (whiteKing(1), e, 1), (blackRook(1), b, 3), (blackKing(1), g, 8)]),
      whiteKnight(1),
      [(b, 3), (c, 2), (e, 2), (f, 3), (f, 5), (e, 6), (c, 6), (b, 5)]).

testKnight(78) :-
      testLegalMove(testKnight4,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), d, 8), (whiteKnight(1), d, 4), (whiteKing(1), d, 3), (blackKing(1), c, 7)]),
      whiteKnight(1),
      []).

testKnight(79) :-
      testLegalMove(testKnight5,
              initialState(computer(whitePlayer), moves(whitePlayer),
      [(blackRook(1), h, 4), (whiteKnight(1), d, 4), (whiteKing(1), c, 4), (blackKing(1), c, 7)]),
      whiteKnight(1),
      []).
